package web

import (
	"log"
	"net/http"
	"time"
)

type Logger struct {
	handler http.Handler
}

func (logger *Logger) ServeHTTP(writer http.ResponseWriter, request *http.Request) {
	start := time.Now()
	logger.handler.ServeHTTP(writer, request)
	log.Printf("%s %s %v\n", request.Method, request.RequestURI, time.Since(start))
}

func NewLogger(handler http.Handler) *Logger {
	return &Logger{handler}
}
